//多态
// 父类
class Animal {
  name: string;
  age: number;
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
    this.eat();
  };
  eat(): void{
    throw new Error('这是父类中的eat方法必须在子类中重写')
  }
};
//子类
class Person extends Animal{
  constructor(name: string, age: number) {
    super(name, age);
  };
  eat() {
    console.log('这是子类复写后的eat方法');
  }
};
let p2 = new Person('王刚', 23);